/*
package com.summer.study.leetcode.tree;

import java.util.ArrayList;
import java.util.List;
import java.util.Stack;

*/
/**
 * @auther: 杨杰
 * @date: 2019/7/29 15:25
 * @description:
 *//*

public class BinaryTreeNode<T> {

    private T val;

    private BinaryTreeNode left;

    private BinaryTreeNode right;

    public BinaryTreeNode(T val) {
        this.val = val;
    }

    public BinaryTreeNode(T val, BinaryTreeNode left, BinaryTreeNode right) {
        this.val = val;
        this.left = left;
        this.right = right;
    }

    public static <V> void dfs(BinaryTreeNode<V> tree, int depth) {
        if (tree != null) {
            //打印节点值以及深度
            System.out.println(tree.getValue().toString() + ",   " + depth);
            if (tree.getChildList() != null && !tree.getChildList().isEmpty()) {
                for (BinaryTreeNode<V> item : tree.getChildList()) {
                    dfs(item, depth + 1);
                }
            }
        }
    }

    */
/**
     * @param root :
     * @auther: 杨杰
     * @date: 2019/7/30 10:02
     * @description 二叉树的深度优先算法 https://blog.csdn.net/CSU174712009/article/details/89389057
     *//*

    public static void dfs(BinaryTreeNode root) {
        if (root == null) {
            return;
        }
        Stack<BinaryTreeNode> stack = new Stack<>();
        stack.add(root);
        while (!stack.isEmpty()) {
            BinaryTreeNode tmpNode = stack.peek();
            System.out.println(stack.pop().val);
            //先右后左
            if (tmpNode.right != null) {
                stack.add(tmpNode.right);
            }
            if (tmpNode.left != null) {
                stack.add(tmpNode.left);
            }
        }
    }


    */
/**
     * @param root :
     * @auther: 杨杰
     * @date: 2019/7/30 9:54
     * @description 是否是排序二叉树
     *//*

    public static boolean isValidBST(BinaryTreeNode root) {
        List<Integer> list = inorderTraversal(root);
        if (list.size() > 2) {
            for (int i = 1; i < list.size() - 1; i++) {
                if (list.get(i - 1) > list.get(i)) {
                    return false;
                }
            }
        }
        return true;
    }

    */
/**
     * @param root :
     * @auther: 杨杰
     * @date: 2019/7/30 9:54
     * @description 中序遍历
     *//*

    public static List inorderTraversal(BinaryTreeNode root) {
        List res = new ArrayList<>();
        if (root != null) inorder(root, res);
        return res;
    }

    public static void inorder(BinaryTreeNode root, List res) {
        if (root.left != null) inorder(root.left, res);
        res.add(root.val);
        if (root.right != null) inorder(root.right, res);
    }

    public static void main(String[] args) {
        BinaryTreeNode TreeNode1 = new BinaryTreeNode(1, null, null);
        BinaryTreeNode TreeNode6 = new BinaryTreeNode(6, null, null);
        BinaryTreeNode TreeNode3 = new BinaryTreeNode(3, null, null);

        BinaryTreeNode TreeNode4 = new BinaryTreeNode(4, TreeNode3, TreeNode6);
        BinaryTreeNode root = new BinaryTreeNode(5, TreeNode1, TreeNode4);
        inorderTraversal(root).stream().forEach(o -> {
            //System.out.println(o.toString());
        });
        //System.out.println("是否是排序二叉树：" + isValidBST(root));

        dfs(root);



    }
}
*/
